package com.caiden_micheal.base.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JsonValidator {
    private static final Logger logger = LoggerFactory.getLogger(JsonValidator.class);

    public static Boolean validJSON(String json) {
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            objectMapper.readTree(json);
            return true;
        } catch (JsonProcessingException e) {
            logger.warn("JSON校验失败,JSON: ", e);
            return false;
        }
    }
}
